package com.steven.im.adapter;


import android.annotation.SuppressLint;
import android.view.View;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.steven.im.R;
import com.steven.im.entity.IMGroupChatListEntity;

import java.util.List;

public class IMGroupChatListAdapter extends BaseQuickAdapter<IMGroupChatListEntity, BaseViewHolder> {
     public IMGroupChatListAdapter(List<IMGroupChatListEntity> item){
         super(R.layout.item_im_groupchat,item);

     }
    @Override
    protected void convert(BaseViewHolder helper, IMGroupChatListEntity item) {
     String name=item.getGroup_name();
        ((TextView)helper.getView(R.id.tv_name)).setText(name);
    }
    private OnItemClickListener mOnItemClickListener = null;

    public interface OnItemClickListener {
        void onClick(int position);

        void onLongClick(int position);
    }

    public void setOnItemClickListener(OnItemClickListener onItemClickListener) {
        this.mOnItemClickListener = onItemClickListener;
    }
    @Override
    public void onBindViewHolder(BaseViewHolder holder, @SuppressLint("RecyclerView") final int position) {
        super.onBindViewHolder(holder, position);
        if (mOnItemClickListener != null) {
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    mOnItemClickListener.onClick(position);
                }
            });
            holder.itemView.setOnLongClickListener(new View.OnLongClickListener() {
                @Override
                public boolean onLongClick(View v) {
                    mOnItemClickListener.onLongClick(position);
                    return true;
                }
            });
        }
    }
}
